﻿namespace Core
{
    public abstract class DataType
    {
        public abstract int TypeId();
        public abstract int SizeInMemory();

        public override int GetHashCode()
        {
            return ToString().GetHashCode();
        }

        public override bool Equals(object obj)
        {
            var other = obj as DataType;
            if (other == null)
            {
                return false;
            }
            return other.ToString() == ToString();
        }
    }

    public class Integer : DataType
    {
        public override int TypeId()
        {
            return 0;
        }

        public override int SizeInMemory()
        {
            return 2;
        }

        public override string ToString()
        {
            return "int";
        }
    }

    public class Float : DataType
    {
        public override int TypeId()
        {
            return 1;
        }

        public override int SizeInMemory()
        {
            return 4;
        }

        public override string ToString()
        {
            return "float";
        }
    }

    public class Boolean : DataType
    {
        public override int TypeId()
        {
            return 2;
        }

        public override int SizeInMemory()
        {
            return 1;
        }

        public override string ToString()
        {
            return "bool";
        }
    }

    public class Void : DataType
    {
        public override int TypeId()
        {
            return -1;
        }

        public override int SizeInMemory()
        {
            return 0;
        }

        public override string ToString()
        {
            return "void";
        }
    }
}